#pragma once
#include "StdAfx.h"
#include "HPReferenceCount.h"

HPReferenceCount::HPReferenceCount()
{
	iReferenceCount = 0;
}
HPReferenceCount::~HPReferenceCount()
{
	CloseHandle(hLock);
}
void HPReferenceCount::retain()
{
	WaitForSingleObject(hLock,INFINITE);
	iReferenceCount ++;
	ReleaseMutex(hLock);
}
void HPReferenceCount::release()
{
	WaitForSingleObject(hLock,INFINITE);
	this->iReferenceCount -- ;
	if(iReferenceCount <= 0)delete this;
	ReleaseMutex(hLock);
}